package com.cn.ccp.action.course.online;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.faces.context.FacesContext;

import org.apache.log4j.Logger;

import com.cn.ccp.action.BaseAction;
import com.cn.ccp.bean.CourseBean;
import com.cn.ccp.bean.OnlineExamBean;

/**
 * 学生调查提交action
 * @author renyongcheng
 *
 */
public class EvaluationAction extends BaseAction {
	private Logger log = Logger.getLogger(EvaluationAction.class);
	private String courseName ,courseId,selectCourseId,settingId;
	private  List<OnlineExamBean> onlineExamList ;
	
	/**
	 * 跳转到提交调查页面
	 * @return
	 */
	public String goEvaluationPages(){
		Map<String, String> varMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
		courseId = varMap.get("courseId");
		selectCourseId = varMap.get("selectedCourseId");
		settingId = varMap.get("settingId");
		log.info("selectedCourseId = "+selectCourseId);
		log.info("courseId = "+courseId);
		log.info("settingId = "+settingId);
		onlineExamList = getOnlineExamService().getCourseResearch(settingId);
		return "evaluation";
	}
	
	
	public String goEvaluationReportPages(){
		Map<String, String> varMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
		courseId = varMap.get("courseId");
		settingId = varMap.get("settingId");
		log.info("courseId = "+courseId);
		log.info("settingId = "+settingId);
		onlineExamList = getOnlineExamService().getCourseSettingReport(settingId);
		return "evaluationReport";
	}
	
	
	/**
	 * 提交调查
	 */
	public String commintResearch(){
		log.info("-----------------onlineExamList.size() = "+onlineExamList.size());
		getCourseInvestigationService().commintInvestigation(settingId, onlineExamList);
		return MAIN;
	}
	
	
	public String getCourseName() {
		CourseBean bean = getCourseService().getBeanById(courseId);
		courseName = bean.getCourse_name();
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public String getCourseId() {
		return courseId;
	}

	public void setCourseId(String courseId) {
		this.courseId = courseId;
	}

	public String getSelectCourseId() {
		return selectCourseId;
	}

	public void setSelectCourseId(String selectCourseId) {
		this.selectCourseId = selectCourseId;
	}

	public String getSettingId() {
		return settingId;
	}

	public void setSettingId(String settingId) {
		this.settingId = settingId;
	}

	public List<OnlineExamBean> getOnlineExamList() {
		if(onlineExamList == null)
			onlineExamList = new ArrayList<OnlineExamBean>();
		return onlineExamList;
	}

	public void setOnlineExamList(List<OnlineExamBean> onlineExamList) {
		this.onlineExamList = onlineExamList;
	}
	
}
